package com.xiaohao.communication.service;

import com.xiaohao.communication.bean.ConcernAndUnsubscribe;
import com.xiaohao.communication.dao.UserConcernAndUnsubscribeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;


/*
* 用户关注与退订
* */
@Service
public class UserConcernAndUnsubscribeService{


    @Autowired
    UserConcernAndUnsubscribeDao userConcernAndUnsubscribeDao;

    //关注用户
    public void concernUser(ConcernAndUnsubscribe concernAndUnsubscribe) {
        userConcernAndUnsubscribeDao.concernUser(concernAndUnsubscribe);
    }


    /*
     * 取消关注用户
     * withusername:被关注用户名
     * Username:关注用户名
     * 传入之后，修改  被关注用户名状态码  ，置为0
     * */
    public void cancelConcernUser(String withUsername, String username) {

        userConcernAndUnsubscribeDao.cancelConcernUser(withUsername, username);

    }


    /*
     * 获取关注用户
     * username：关注用户名
     * 传入 关注用户名，
     * */
    public List<ConcernAndUnsubscribe> getConcernUser(String username) {
        List<ConcernAndUnsubscribe> concernUser = userConcernAndUnsubscribeDao.getConcernUser(username);
        return concernUser;

    }



    /*******************************/

    //关注话题

    public void concernTopic(ConcernAndUnsubscribe concernAndUnsubscribe) {
        userConcernAndUnsubscribeDao.concernTopic(concernAndUnsubscribe);
    }

    //取消关注话题
    /*
    * topic_id  ： 关注话题id
    * username  ： 关注用户
    * 传入参数 设置被关注话题状态码 为 0；
    * */
    public void cancelConcernTopic(int topic_id, String username) {

        userConcernAndUnsubscribeDao.cancelConcernTopic(topic_id, username);

    }


    //获取关注话题
    public List<ConcernAndUnsubscribe> getConcernTopic(String username) {

        List<ConcernAndUnsubscribe> concernTopic = userConcernAndUnsubscribeDao.getConcernTopic(username);
        return concernTopic;

    }



}
